package cn.etouch.huangli;

import java.util.ArrayList;
import java.util.regex.MatchResult;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class GetMessageFromNet {
	public static ArrayList<HuangliOfOneDay> getLines(String monthkey,String daykey){
		ArrayList<HuangliOfOneDay> lines=new ArrayList<HuangliOfOneDay>();
		HuangliOfOneDay huangone = new HuangliOfOneDay();
				System.out.println(monthkey);
				System.out.println(daykey);
				String retStr=NetManager.sendGet(StaticString.url+StaticString.part1+monthkey+"-"+daykey+StaticString.part2, "");
				String regEx1="<div class=\"btw2\">.*?</div>";
//				String regEx1="<li><li>.*?</li></li>";
				Pattern   p1   =   Pattern.compile(regEx1);
		        Matcher   m1   =   p1.matcher(retStr);
		        if(m1.find()){
		        	MatchResult mr=m1.toMatchResult(); 
		        	System.out.println(mr.group());
		        	for (int i = 0; i < 11; i++) {
		        		switch (i) {
						case 0:	
							huangone= new HuangliOfOneDay();
							String regEx0="【公.*?</li>";
				        	Pattern   p0   =   Pattern.compile(regEx0);      
					        Matcher   m0   =   p0.matcher(mr.group());
					        if(m0.find()){
					        	MatchResult mr2=m0.toMatchResult(); 
					        	String s0 = mr2.group();
					        	huangone.date = s0.substring(5, s0.length()-5).replaceAll("[\u4e00-\u9fa5]", "");
					        }
							break;
						case 1:
							String regEx2="【每.*?</li>";
				        	Pattern   p2   =   Pattern.compile(regEx2);      
					        Matcher   m2   =   p2.matcher(mr.group());
					        if(m2.find()){
					        	
					        	MatchResult mr2=m2.toMatchResult(); 
					        	String s0 = "<li>"+mr2.group();
					        	huangone.dayoffangxiang = s0.substring(4, s0.length()-5);
//					        	System.out.println(s0.substring(4, s0.length()-5));
					        }
							break;
						case 2:
							String regEx3="【五.*?</li>";
				        	Pattern   p3   =   Pattern.compile(regEx3);      
					        Matcher   m3   =   p3.matcher(mr.group());
					        if(m3.find()){
					        	
					        	MatchResult mr2=m3.toMatchResult(); 
					        	String s0 = "<li>"+mr2.group();
					        	huangone.five = s0.substring(4, s0.length()-5);
					        }
							break;
						case 3:
							String regEx4="【冲.*?</li>";
				        	Pattern   p4   =   Pattern.compile(regEx4);      
					        Matcher   m4   =   p4.matcher(mr.group());
					        if(m4.find()){
					        	
					        	MatchResult mr2=m4.toMatchResult(); 
					        	String s0 = "<li>"+mr2.group();
					        	huangone.chong = s0.substring(4, s0.length()-5);
//					        	System.out.println(s0.substring(4, s0.length()-5));
					        }
							break;
						case 4:
							String regEx5="【彭.*?</li>";
				        	Pattern   p5   =   Pattern.compile(regEx5);      
					        Matcher   m5   =   p5.matcher(mr.group());
					        if(m5.find()){
					        	
					        	MatchResult mr2=m5.toMatchResult(); 
					        	String s0 = "<li>"+mr2.group();
					        	huangone.pengzubaiji = s0.substring(4, s0.length()-5);
//					        	System.out.println(s0.substring(4, s0.length()-5));
					        }
							break;
						case 5:
							String regEx6="【吉.*?</li>";
				        	Pattern   p6   =   Pattern.compile(regEx6);      
					        Matcher   m6   =   p6.matcher(mr.group());
					        if(m6.find()){
					        	
					        	MatchResult mr2=m6.toMatchResult(); 
					        	String s0 = "<li>"+mr2.group();
					        	huangone.jishengyiqu = s0.substring(4, s0.length()-5);
//					        	System.out.println(s0.substring(4, s0.length()-5));
					        }
							break;
						case 6:
							String regEx7="【宜.*?</li>";
				        	Pattern   p7   =   Pattern.compile(regEx7);      
					        Matcher   m7   =   p7.matcher(mr.group());
					        if(m7.find()){
					        	
					        	MatchResult mr2=m7.toMatchResult(); 
					        	String s0 = "<li>"+mr2.group();
					        	huangone.yi = s0.substring(4, s0.length()-5);
//					        	System.out.println(s0.substring(4, s0.length()-5));
					        }
							break;
						case 7:
							String regEx8="【凶.*?</li>";
				        	Pattern   p8   =   Pattern.compile(regEx8);      
					        Matcher   m8   =   p8.matcher(mr.group());
					        if(m8.find()){
					        	
					        	MatchResult mr2=m8.toMatchResult(); 
					        	String s0 = "<li>"+mr2.group();
					        	huangone.xiongshengyiji = s0.substring(4, s0.length()-5);
//					        	System.out.println(s0.substring(4, s0.length()-5));
					        }
							break;
						case 8:
							String regEx9="【忌.*?</li>";
				        	Pattern   p9   =   Pattern.compile(regEx9);      
					        Matcher   m9   =   p9.matcher(mr.group());
					        if(m9.find()){
					        	MatchResult mr2=m9.toMatchResult(); 
					        	String s0 = "<li>"+mr2.group();
					        	huangone.ji = s0.substring(4, s0.length()-5);
//					        	System.out.println(s0.substring(4, s0.length()-5));
					        }
					       
							break;
						default:
							break;
						}
		        		lines.add(huangone);
					}
		        }
		return lines;
	}
}